<%@ page language="java" %>

<%@ page import="com.scalar.chiptrack.commons.SessionKeys,
                 com.scalar.chiptrack.utils.ConfigManager,
				 com.scalar.chiptrack.commons.Constants,
				 com.scalar.chiptrack.users.Functionality,
				 com.scalar.chiptrack.users.User,
                 com.scalar.chiptrack.operations.release.ProgramReleaseObject"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext(); %>
<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet"></HEAD>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>

<SCRIPT language="JavaScript">
window.onload = init;

function init()
{
    qs_1 = new QuickSearch(document.testReleaseSearchForm.processStep_ID, document.testReleaseSearchForm.qs1, false);
}

function view( releaseId )
{
    document.testReleaseSearchForm.action = '<%=chipTracContext%>/testRelease.do?action=view&releaseId=' + releaseId;
    document.testReleaseSearchForm.submit();
}

function modify( releaseId )
{
    document.testReleaseSearchForm.action = '<%=chipTracContext%>/testRelease.do?action=modify&releaseId=' + releaseId;
    document.testReleaseSearchForm.submit();
}

function approve( releaseId )
{
    document.testReleaseSearchForm.action = '<%=chipTracContext%>/testRelease.do?action=approve&releaseId=' + releaseId;
    document.testReleaseSearchForm.submit();
}

function cancel( releaseId )
{
    document.testReleaseSearchForm.action = '<%=chipTracContext%>/testRelease.do?action=cancel&releaseId=' + releaseId;
    document.testReleaseSearchForm.submit();
}

function ship( releaseId )
{
    document.testReleaseSearchForm.action = '<%=chipTracContext%>/testRelease.do?action=ship&releaseId=' + releaseId;
    document.testReleaseSearchForm.submit();
}

function reset()
{
    document.testReleaseSearchForm.reset();
    qs_1.resetQuickSearchCntrl();
}

</SCRIPT>

<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
<html:form name="testReleaseSearchForm" type="com.scalar.chiptrack.operations.release.forms.TestReleaseSearchForm" action="/testReleaseSearch?action=search" method="POST">

<!-- Top Header Start-->
	<logic:equal name="testReleaseSearchForm" property="userType" value="1">
		<%@ include file="/jsp/includes/header.jsp" %>
	</logic:equal>
	<logic:equal name="testReleaseSearchForm" property="userType" value="0">
		<%@include file="/jsp/includes/extHeader.jsp"  %>
	</logic:equal>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
	<TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

	<!-- Side Navigation start -->
	<logic:equal name="testReleaseSearchForm" property="userType" value="1">
		<%@ include file="/jsp/operations/releaseMenu.jsp" %></TD>
	</logic:equal>
	<logic:equal name="testReleaseSearchForm" property="userType" value="0">
		<%@ include file="/jsp/admin/externaluser_menu.jsp" %></TD>
	</logic:equal>
	<!-- end of the side navigations -->

	<TD bgcolor="#ffffff">
	<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
	<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
	<TD valign="top" width="100%">

	<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
	<BR>

		<TABLE width="95%" align="right" cellpadding="2" cellspacing="2" border="0">
			<TR><TD colspan="4" class="NArialW" align="center">Programming Release Search</TD></TR>

			<TR><TD colspan='4' align="left" class='NArialL'>&nbsp;<FONT id="errors" color='FF0000'></font></TD></TR>
			<TR><TD colspan='4' class="NArialL"><chiptrack:errors styleClass="NArialL"/></TD></TR>
			<TR><TD colspan='4' class="NArialL"><chiptrack:info styleClass="NArialL"/></TD></TR>
			<TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>

			<tr>
            <td class="NArialL" width='30%'>
            Quick Search <bean:message key="label.mfgPartNumber"/>:
            </td>
            <td class="NArialL" width='20%'>
            <input type="text" name="qs1" class="txfield" size='12' onkeyup='quickSearch(qs_1)'/>
            </td>
            <td colspan='2' width='50%'>&nbsp;</td>
            </tr>

            <tr>
			<td class="NArialL">
			<bean:message key="label.mfgPartNumber"/>:
			</td>
			<td class="NArialL">
			<html:select name="testReleaseSearchForm" property="processStep_ID"  styleClass="txfield">
				<html:option value="-1">All</html:option>
				<html:options collection="partNumberList" property="value" labelProperty="label"/>
			</html:select>
			</td>

			<td class="NArialL">
			Status:
			</td>
			<td class="NArialL">
			<html:select name="testReleaseSearchForm" property="status"  styleClass="txfield">
				<html:options collection="statusList" property="value" labelProperty="label"/>
                <html:option value="-1">All</html:option>
			</html:select>
			</td>
			</tr>

			<tr>
				<td class="NArialL">
					Customer:
				</td>
				<td class="NArialL">
					<html:select name="testReleaseSearchForm" property="customer_ID"  styleClass="txfield">
						<html:options collection="customerList" property="value" labelProperty="label"/>
					</html:select>
				</td>

				<td class="NArialL">
					Sales Order #:
				</td>
				<td class="NArialL">
					<html:text name="testReleaseSearchForm" property="salesOrder_No" styleClass="txfield"/>
				</td>
			</tr>
			
			<tr>
			<td class="NArialL">
			Vendor:
			</td>
			<td class="NArialL">
			<html:select name="testReleaseSearchForm" property="vendor_ID"  styleClass="txfield">
				<html:option value="-1">All</html:option>
				<html:options collection="vendorList" property="value" labelProperty="label"/>
			</html:select>
			</td>

			<td class="NArialL">
			Year:
			</td>
			<td class="NArialL">
			<html:select name="testReleaseSearchForm" property="year"  styleClass="txfield">
				<html:option value="-1">All</html:option>
				<html:options collection="yearList" property="value" labelProperty="label"/>
			</html:select>
			</td>
			</tr>
			<TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
			<tr>
				<td colspan="5" align="center">
                 <input type=image border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Search for Programming Release Forms';return true" onmouseout="window.status='';return true" title="Click here to Search for Programming Request entries">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<a href="javascript:reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
				</td>
			</tr>

			<tr>
				<td colspan="5" align="center">&nbsp;
				</td>
			</tr>
			<logic:equal name="testReleaseSearchForm" property="userType" value="1">

			<tr><td colspan='4' class="NArialL">Please <chiptrack:restrictedLink functionality='<%=Functionality.PROGRAMMING_RELEASE %>' action='<%=User.USER_ACTION_MODIFY%>' styleClass="leftsection" href='<%=chipTracContext+"/newTestRelease.do"%>'
                                onmouseover="window.status='Click to Generate Programming Release';return true" onmouseout="window.status='';return true">click here</chiptrack:restrictedLink> to generate new Programming Release</tr></td>
	
			</logic:equal>

			<logic:present name="progReleaseObjectList">
            <tr><td colspan='4'>
                <TABLE border=0 cellspacing=1 cellpadding=1 class='NArialL'>
                    <tr>
                        <td bgcolor="#993333" width="10%" align="center"><font color="#FFFFFF">Release #</font></td>
                        <td bgcolor="#993333" width="10%" align="center"><font color="#FFFFFF">Sales Order #</font></td>
                        <td bgcolor="#993333" width="5%" align="center"><font color="#FFFFFF">Line<br>Item #</font></td>
                        <td bgcolor="#993333" width="5%" align="center"><font color="#FFFFFF">Shipment<br>#</font></td>
                        <td bgcolor="#993333" width="10%" align="center"><font color="#FFFFFF">PO Number</font></td>
                        <td bgcolor="#993333" width="15%" align="center"><font color="#FFFFFF"><bean:message key="label.mfgPartNumber"/></font></td>
                        <td bgcolor="#993333" width="15%" align="center"><font color="#FFFFFF">Description</font></td>
                        <td bgcolor="#993333" width="15%" align="center"><font color="#FFFFFF">Customer</font></td>
                        <td bgcolor="#993333" width="7%" align="center"><font color="#FFFFFF">Issued<br>Qty</font></td>
                        <td bgcolor="#993333" width="7%" align="center"><font color="#FFFFFF">Issued Date</font></td>
                        <td bgcolor="#993333" width="7%" align="center"><font color="#FFFFFF">Expected Completion Date</font></td>
						<td bgcolor="#993333" width="7%" align="center"><font color="#FFFFFF">Vendor</font></td>
                        <td bgcolor="#993333" width="7%" align="center"><font color="#FFFFFF">Order Type</font></td>
                        <td bgcolor="#993333" width="7%" align="center"><font color="#FFFFFF">Status</font></td>
                        <td bgcolor="#993333" width="20%" align="center" colspan="4"><font color="#FFFFFF">Actions</font></td>
                    </tr>

					<logic:iterate id="progRelease" name="progReleaseObjectList" indexId="iteratorIdx">
                    <tr <%if(iteratorIdx.intValue()%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>>

					    <td width="10%" align="center"><bean:write name="progRelease" property="prog_Release_No"/></td>
                        <td width="10%" align="center"><bean:write name="progRelease" property="salesOrderNo"/></td>
                        <td width="5%" align="center"><bean:write name="progRelease" property="lineItem_No"/></td>
                        <td width="5%" align="center"><bean:write name="progRelease" property="shipmentNumber"/></td>
                        <td width="10%" align="center"><bean:write name="progRelease" property="customer_PO_Number"/></td>
                        <td width="15%" align="center"><bean:write name="progRelease" property="partNumber"/></td>
                        <td width="15%" align="center"><bean:write name="progRelease" property="blankPartDescription"/></td>
                        <td width="15%" align="center"><bean:write name="progRelease" property="customerName"/></td>
                        <td width="7%" align="center"><bean:write name="progRelease" property="orderQty"/></td>
                        <td width="7%" align="center"><bean:write name="progRelease" property="issueDate"/></td>
                        <td width="7%" align="center"><bean:write name="progRelease" property="expectedCompletionDate"/></td>
						<td width="7%" align="center"><bean:write name="progRelease" property="vendorName"/></td>
                        <td width="7%" align="center"><bean:write name="progRelease" property="orderType"/></td>
                        <td width="7%" align="center"><bean:write name="progRelease" property="status"/></td>
						<bean:define name="progRelease" property="status" id="releaseStatus"/>
                        <bean:define name="progRelease" property="prog_Release_Id" id="progReleaseId"/>
						<td><table cellspacing=2 cellpadding=3 class='NArialL'><tr>
                        <%
                            /*String modifyUrl  = "javascript:modify("+((ProgramReleaseObject)progRelease).getProg_Release_Id()+");";
                            String approveUrl = "javascript:approve("+((ProgramReleaseObject)progRelease).getProg_Release_Id()+");";
                            String cancelUrl  = "javascript:cancel("+((ProgramReleaseObject)progRelease).getProg_Release_Id()+");";
                            String shipUrl    = "javascript:ship("+((ProgramReleaseObject)progRelease).getProg_Release_Id()+");";*/
                            int releaseId = ((ProgramReleaseObject)progRelease).getProg_Release_Id();
                        %>
						<logic:equal name="testReleaseSearchForm" property="userType" value="1">

                        <td width="5%" align="center">
       						<A Href="<%=chipTracContext%>/testRelease.do?action=view&releaseId=<bean:write name='progRelease' property='prog_Release_Id'/>" onmouseover="window.status='Click to View Programming Release';return true" onmouseout="window.status='';return true">
							View
							</A>
                        </td>
                        <td  width="5%" align="center">
							<% 
							if( !( Constants.CUSTOMER_SHIPPING_STATUS_CANCELLED ).equalsIgnoreCase( (java.lang.String)releaseStatus ) && !( Constants.CUSTOMER_SHIPPING_STATUS_SHIPPED ).equalsIgnoreCase( (java.lang.String)releaseStatus ) )
							{

							%>
                            <chiptrack:restrictedLink functionality='<%=Functionality.PROGRAMMING_RELEASE %>' action='<%=User.USER_ACTION_MODIFY%>' styleClass="leftsection" href='<%=chipTracContext+"/testRelease.do?action=modify&releaseId="+releaseId%>'
                                onmouseover="window.status='Click to Modify Programming Release';return true" onmouseout="window.status='';return true">Modify</chiptrack:restrictedLink>
							<%
							}
							else
							{
							%>
							Modify
							<%
							}
							%>
                        </td>
                        <td width="5%" align="center">
							<% 
							if( ( Constants.CUSTOMER_SHIPPING_STATUS_ISSED ).equalsIgnoreCase( (java.lang.String)releaseStatus ) )
							{
							%>
                            <chiptrack:restrictedLink functionality='<%=Functionality.APPROVE_PROGRAMMING_RELEASE %>' action='<%=User.USER_ACTION_MODIFY%>' styleClass="leftsection" href='<%=chipTracContext+"/testRelease.do?action=approve&releaseId="+releaseId%>'
                                onmouseover="window.status='Click to Approve Programming Release';return true" onmouseout="window.status='';return true">Approve</chiptrack:restrictedLink>
							<%
							}
							else if( ( Constants.SALESORDER_STATUS_APPROVED ).equalsIgnoreCase( (java.lang.String)releaseStatus ) )
							{
							%>
                            <chiptrack:restrictedLink functionality='<%=Functionality.APPROVE_PROGRAMMING_RELEASE %>' action='<%=User.USER_ACTION_MODIFY%>' styleClass="leftsection" href='<%=chipTracContext+"/testRelease.do?action=ship&releaseId="+releaseId%>'
                                onmouseover="window.status='Click to Ship Programming Release';return true" onmouseout="window.status='';return true">Ship</chiptrack:restrictedLink>
							<%
							}
							else
							{
							%>
							Approve
							<%
							}
							%>
                        </td>
                        <td width="5%" align="center">
							<% 
							if( !( Constants.CUSTOMER_SHIPPING_STATUS_CANCELLED ).equalsIgnoreCase( (java.lang.String)releaseStatus ) && !( Constants.CUSTOMER_SHIPPING_STATUS_SHIPPED ).equalsIgnoreCase( (java.lang.String)releaseStatus ) )
							{
							%>
                            <chiptrack:restrictedLink functionality='<%=Functionality.CANCEL_PROGRAMMING_RELEASE %>' action='<%=User.USER_ACTION_MODIFY%>' styleClass="leftsection" href='<%=chipTracContext+"/testRelease.do?action=cancel&releaseId="+releaseId%>'
                                onmouseover="window.status='Click to Cancel Programming Release';return true" onmouseout="window.status='';return true">Cancel</chiptrack:restrictedLink>
							<%
							}
							else
							{
							%>
							Cancel
							<%
							}
							%>
                        </td>
						</logic:equal>

						<!-- THIS IS FOR EXTRENAL USER LOGIN -->
						
						<logic:equal name="testReleaseSearchForm" property="userType" value="0">

                        <td width="5%" align="center">
                            <A Href="<%=chipTracContext%>/testRelease.do?action=view&releaseId=<bean:write name='progRelease' property='prog_Release_Id'/>" onmouseover="window.status='Click to View Programming Release';return true" onmouseout="window.status='';return true">
							View
							</A>
                        </td>
                        <td  width="5%" align="center">
							<% 
							if( ( Constants.SALESORDER_STATUS_APPROVED ).equalsIgnoreCase( (java.lang.String)releaseStatus ) )
							{
							%>
                            <chiptrack:externalRestrictedLink functionality='<%=Functionality.PROGRAMMING_RELEASE %>' action='<%=User.USER_ACTION_MODIFY%>' styleClass="leftsection" href='<%=chipTracContext+"/testRelease.do?action=modify&releaseId="+releaseId%>'
                                onmouseover="window.status='Click to Modify Programming Release';return true" onmouseout="window.status='';return true">Modify</chiptrack:externalRestrictedLink>
							<%
							}
							else
							{
							%>
							Modify
							<%
							}
							%>
                        </td>
                        <td width="5%" align="center">
							<% 
							if( ( Constants.SALESORDER_STATUS_APPROVED ).equalsIgnoreCase( (java.lang.String)releaseStatus ) )
							{
							%>
       						<chiptrack:externalRestrictedLink functionality='<%=Functionality.SHIP_PROGRAMMING_RELEASE %>' action='<%=User.USER_ACTION_MODIFY%>' styleClass="leftsection" href='<%=chipTracContext+"/testRelease.do?action=ship&releaseId="+releaseId%>'
                                onmouseover="window.status='Click to Ship Programming Release';return true" onmouseout="window.status='';return true">Ship</chiptrack:externalRestrictedLink>
							<%
							}
							else
							{
							%>
							Ship
							<%
							}
							%>
                        </td>
						</logic:equal>

						</tr></table></td>
                    </tr>
					</logic:iterate>

                </TABLE>

            </td></tr>

			</logic:present>

		</TABLE>

<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
</html:form>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>